//
//  UIButton+Url.m
//  TojoyCloud
//
//  Created by yuntai on 2017/10/31.
//  Copyright © 2017年 _Engineer_雷海洋_. All rights reserved.
//

#import "UIButton+Url.h"
#import <UIButton+WebCache.h>

@implementation UIButton (Url)

- (void)sd_setimageWithUrlStr:(NSString *)urlStr{
    
    if ([urlStr containsString:@"http://"]||[urlStr containsString:@"https://"]) {
        
        [self sd_setImageWithURL:[NSURL URLWithString:urlStr] forState:UIControlStateNormal placeholderImage:[UIImage imageNamed:@"Default_Life"]];
    }else{
        
        [self sd_setImageWithURL:[NSURL URLWithString:[kAliOSSRootURL stringByAppendingString:urlStr]] forState:UIControlStateNormal placeholderImage:[UIImage imageNamed:@"Default_Life"]];
    }
    
}

- (void)sd_setBackgroundImageWithUrlStr:(NSString *)urlStr{
    
    if ([urlStr containsString:@"http://"]||[urlStr containsString:@"https://"]) {
        
        [self sd_setBackgroundImageWithURL:[NSURL URLWithString:urlStr] forState:UIControlStateNormal placeholderImage:[UIImage imageNamed:@"Default_Life32"]];
    }else{
        
        [self sd_setBackgroundImageWithURL:[NSURL URLWithString:[kAliOSSRootURL stringByAppendingString:urlStr]] forState:UIControlStateNormal placeholderImage:[UIImage imageNamed:@"Default_Life32"]];
    }
    
}

- (void)sd_setimageWithUrlStr:(NSString *)urlStr placeholder:(NSString *)placeholderName{
    if ([urlStr containsString:@"http://"]||[urlStr containsString:@"https://"]) {
        
        [self sd_setImageWithURL:[NSURL URLWithString:urlStr] forState:UIControlStateNormal placeholderImage:[UIImage imageNamed:placeholderName?:@"Default_Life"]];

    }else{
        
        
         [self sd_setImageWithURL:[NSURL URLWithString:[kAliOSSRootURL stringByAppendingString:urlStr]] forState:UIControlStateNormal placeholderImage:[UIImage imageNamed:placeholderName?:@"Default_holder_image"]];
        
    }
    
}

@end
